<template>
	<div class="agent-com">
		<navTitle title="ۋاكالەتچىلىك مەركىزى"></navTitle>
		<scroll>
			<giantScreen @handleRefresh='handleRefresh' :userInfo="userInfo" :pulum='pulum'></giantScreen>
			<info :mukapat='mukapat' :appInfo='appInfo'></info>
		</scroll>
	</div>
</template>

<script>
	import {
		getAgentIndexData
	} from '@/api/agent.js'
	import {
		userInfoMixin
	} from '@/mixins/userInfo.js'
	import navTitle from '@/components/agent/navTitle.vue'
	import giantScreen from '@/components/agent/giantScreen.vue'
	import scroll from '@/components/agent/scroll.vue'
	import info from '@/components/agent/info.vue'
	export default {
		mixins: [userInfoMixin],
		components: {
			giantScreen,
			scroll,
			navTitle,
			info,
		},
		data() {
			return {
				// userInfo: {},
				mukapat: {},
				appInfo: {},
				agentInfo: {},
				pulum: {},
			}
		},
		async mounted() {
			this.$emit('setLoading', true)
			await this.userInfo_init()
			await this.getAgentIndex()
			this.$emit('setLoading', false)
		},
		methods: {
			handleRefresh() {
				this.getUserInfoByLogin() // 通过重新请求登录接口获取userInfo 更新数据
				this.getAgentIndex()
			},
			async getAgentIndex() {
				const res = await getAgentIndexData()
				if (res) {
					this.agentInfo = res.data.data
					this.appInfo = res.data.data.salon
					this.mukapat = res.data.data.mukapat
					this.pulum = res.data.data.pulum
				} else {
					uni.showToast({
						title: '请求失败',
						icon: 'error'
					})
				}
			},
		},
	}
</script>

<style lang="scss" scoped>
	.agent-com {}
</style>